﻿@using Himall.Model;
@{
    ViewBag.Title = "我的订单";
    Dictionary<long , ShopBonusInfo> bonusGrant = null;
    if( ViewBag.BonusGrantIds != null )
    {
        bonusGrant = ( Dictionary<long , ShopBonusInfo> )ViewBag.BonusGrantIds;
    }

}
<div class="container">
    <div class="my_menu">
        <ul class="clearfix">
            <li><a onclick="userOrders(0)">全部订单@*@(ViewBag.AllOrders == 0 ? "" : "(" + ViewBag.AllOrders + ")")*@</a></li>
            <li><a onclick="userOrders(1)">待付款@(ViewBag.WaitingForPay == 0 ? "" : "(" + ViewBag.WaitingForPay + ")")</a></li>
            <li><a onclick="userOrders(3)">待收货@(ViewBag.WaitingForRecieve == 0 ? "" : "(" + ViewBag.WaitingForRecieve + ")")</a></li>
            <li><a onclick="userOrders(5)">待评价@(ViewBag.WaitingForComments == 0 ? "" : "(" + ViewBag.WaitingForComments + ")")</a></li>
        </ul>
    </div>

    <ul class="order-list">
    </ul>
    @*<div class="custom-dialog orderL"  id="paymentsChooser01">
        <span class="glyphicon glyphicon-remove close" aria-hidden="true"></span>
        <h3>恭喜你获得<span>2</span>个红包</h3>
        <span class="share">把他分享给好友吧</span>
        <p class="bg"><img src="~/Areas/Mobile/Templates/Default/Images/dialog.png"></p>
        <p><a class="btn" href="#" type="button">分享给好友</a></p>
    </div>*@


@if( bonusGrant != null && bonusGrant.Count == 1 )
{
    KeyValuePair<long , ShopBonusInfo> bonus = new KeyValuePair<long , ShopBonusInfo>();
    foreach( var b in bonusGrant )
    {
        bonus = b;
        break;
    }
    <div class="custom-dialog orderL"  id="paymentsChooser01">
        <span class="glyphicon glyphicon-remove close" aria-hidden="true"></span>
        <h3>恭喜你获得<span>@bonus.Value.Count</span>个红包</h3>
        <span class="share">把他分享给好友吧</span>
        <p class="bg"><img src="~/Areas/Mobile/Templates/Default/Images/dialog.png"></p>
        <p><a class="btn" href="#" type="button">分享给好友</a></p>
    </div>
    <div class="cover-d"></div>
    <div class="share-guide"></div>
    <div class="loading hide" id="autoLoad"><span></span></div>
}
else if( bonusGrant != null && bonusGrant.Count > 0 )
{
    <div class="custom-dialog  orderL" id="paymentsChooser02">
            <div class="close"><span class="glyphicon glyphicon-remove " aria-hidden="true"></span></div>
            <h3>恭喜你获得<span>@bonusGrant.Count</span>个店家红包</h3>
            <span class="share">把他分享给好友吧</span>
            <p class="bg"><img src="~/Areas/Mobile/Templates/Default/Images/dialog.png"></p>
            @foreach( var bonus in bonusGrant )
            { 
                <p class="pname">@bonus.Value.Himall_Shops.ShopName<a class="bn" onclick="grant('@bonus.Key' , '@bonus.Value.ShareTitle', '@bonus.Value.ShareDetail', '@bonus.Value.ShareImg')">我要发红包>></a></p>    
            }
        </div>
    <div class="cover-d"></div>
    <div class="share-guide"></div>
    <div class="loading hide" id="autoLoad"><span></span></div>
}
    <div class="custom-dialog" id="paymentsChooser"></div>
    @*<div class="cover" style="display:none;"></div>*@
</div>

@if( bonusGrant != null && bonusGrant.Count == 1 )
{
    KeyValuePair<long , ShopBonusInfo> bonus = new KeyValuePair<long,ShopBonusInfo>();
    foreach( var b in bonusGrant )
    {
        bonus = b;
        break;
    }
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script> 
<script type="text/javascript">
    function grant( id , title , des , img)
    {
        wx.onMenuShareAppMessage({
            title: title,
            desc: des,
            link: '@ViewBag.Path' + id,
            imgUrl: '@ViewBag.BaseAddress'+ img,
            type: 'link',
            dataUrl: '',
            success: function (res) {
                $(".share-guide").hide();

            },
            cancel: function (res) {
            }
        });

        wx.onMenuShareTimeline({
            title: title,
            link: '@ViewBag.Path' + id,
            imgUrl: '@ViewBag.BaseAddress'+ img,
            success: function () {
                $(".share-guide").hide();
            },
            cancel: function () {

            }
        });
    }
    wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: '@ViewBag.AppId', // 必填，公众号的唯一标识
        timestamp: @ViewBag.Timestamp , // 必填，生成签名的时间戳
        nonceStr: '@ViewBag.NonceStr', // 必填，生成签名的随机串
        signature: '@ViewBag.Signature',// 必填，签名，见附录1
        jsApiList: [ 'onMenuShareTimeline' , 'onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });

    wx.ready(function () {
        // 判断当前版本是否支持指定 JS 接口，支持批量判断
        wx.checkJsApi({
            jsApiList: [ 'onMenuShareTimeline' , 'onMenuShareAppMessage' ],
            success: function (res)
            {
                grant('@bonus.Key' , '@bonus.Value.ShareTitle', '@bonus.Value.ShareDetail', '@bonus.Value.ShareImg');
                
                LoadBody();
            }
        });
    });

    function LoadBody()
    {
        $("#paymentsChooser01 .btn").click(function(){
            $(".share-guide").show();
        })
        $(".share-guide").click(function(){
            $(this).hide();
        })

        $( ".cover-d" ).addClass( "cover" );
        $( "#paymentsChooser01" ).show();
        $( "#paymentsChooser01" ).css("display" , "block");
        $( ".close" ).click( function ()
        {
            $( "#paymentsChooser01" ).hide();
            $( ".cover-d" ).removeClass( "cover" );
        } );
    }

    
</script>
}
else if( bonusGrant != null && bonusGrant.Count > 0 )
{
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
    wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: '@ViewBag.AppId', // 必填，公众号的唯一标识
        timestamp: @ViewBag.Timestamp , // 必填，生成签名的时间戳
        nonceStr: '@ViewBag.NonceStr', // 必填，生成签名的随机串
        signature: '@ViewBag.Signature',// 必填，签名，见附录1
        jsApiList: [ 'onMenuShareTimeline' , 'onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });

    wx.ready(function () {
        // 判断当前版本是否支持指定 JS 接口，支持批量判断
        wx.checkJsApi({
            jsApiList: [ 'onMenuShareTimeline' , 'onMenuShareAppMessage' ],
            success: function (res)
            {
                LoadBody();
            }
        });
    });

    function LoadBody()
    {
        $("#paymentsChooser02 .bn").click(function(){
            $(".share-guide").show();  
        })
        $(".share-guide").click(function(){
            $(this).hide();
        })

        $( ".cover-d" ).addClass( "cover" );
        $( "#paymentsChooser02" ).show();
        $( "#paymentsChooser02" ).css("display" , "block");
        $( ".close" ).click( function ()
        {
            $( "#paymentsChooser02" ).hide();
            $( ".cover-d" ).removeClass( "cover" );

        } );
    }

    function grant( id , title , des , img)
    {
        wx.onMenuShareAppMessage({
            title: title,
            desc: des,
            link: '@ViewBag.Path' + id,
            imgUrl: '@ViewBag.BaseAddress'+ img,
            type: 'link',
            dataUrl: '',
            success: function (res) {
                $(".share-guide").hide();
            },
            cancel: function (res) {
            }
        });

        wx.onMenuShareTimeline({
            title: title,
            link: '@ViewBag.Path' + id,
            imgUrl: '@ViewBag.BaseAddress'+ img,
            success: function () {
                $(".share-guide").hide();
            },
            cancel: function () {

            }
        });

        
    }
</script>
}
<script src="~/Areas/Mobile/Templates/Default/Scripts/memberOrders.js"></script>

